function wordType(str1,str2){
    let arr1 = str1.split("")
    let arr2 = str2.split(" ")
    if(arr1.length !== arr2.length ) return false;
    let map1 = new Map();
    let map2 = new Map();

    for (let i = 0; i < arr1.length; i++) {
        if(map1.get(arr1[i])){
            if(map1.get(arr1[i]) != arr2[i]){
                return false
            }
        }else {
            map1.set(arr1[i],arr2[i])
        }

        if(map2.get(arr2[i])){
            if(map1.get(arr2[i]) != arr1[i]){
                return false
            }
        }else {
            map1.set(arr1[i],arr2[i])
        }
    }

    return true

}

console.log(wordType("abba", "c d d c"))
console.log(wordType("abcd", "e f d c"))
console.log(wordType("cccd", "cat cat dog fish"))